#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 1e6;
ll n, k, sum[N];

struct node
{
	ll a, b, total;
}item[N];

bool cmp(node t1, node t2)
{
	return t1.total <= t2.total;
}

bool check(int mid)
{
	return k - sum[mid-1] > 0;
}

int main()
{
	cin >> n >> k;
	for(int i=1; i<=n; i++)	cin >> item[i].a;
	for(int i=1; i<=n; i++)	cin >> item[i].b;
	for(int i=1; i<=n; i++)	
	{
		item[i].total = item[i].a + item[i].b;
	}
	sort(item+1, item+1+n, cmp);
	for(int i=1; i<=n; i++)	
	{
		sum[i] = sum[i-1] + item[i].total;
	}
	
	ll l=0, r=n+1;
	while(l+1 < r)
	{
		ll mid = (l+r) >> 1;
		if(check(mid))
			l = mid;
		else
		{
			r = mid;
		}
	}
	cout << l << endl;
	return 0;
}